<template>
	<view>
		<uni-section :title="examInfo.testPaperInfoName" type="line"></uni-section>
		<view class="example-body">
			<uni-card 
			  :is-shadow="true"
			  mode="style" 
			  :extra="studentInfo.name" note="true" @click="clickCard">
				<block slot="footer">
					<view class="footer-box">
						
						<view>
						  <text class="footer-box__item">
							  得分 {{examInfo.systemMark}}分
						  </text>
						</view>
						
						<view>
						  <text class="footer-box__item">
							  耗时 {{examInfo.examTime}}
						  </text>
						</view>
						
						<view>
						  <text class="footer-box__item">
							  排名 5
						  </text>
						</view>
					</view>
				</block>
			</uni-card>
			
			<uni-card
			 :is-shadow="true"
			  mode="style" 
			   note="true" @click="clickCard">
				<block slot="footer">
					<view class="footer-box">
						<view>
						 
						<!-- <uni-badge class="uni-badge-left-margin" text="1" /> -->
						 <text class="footer-box__item">答对题 {{examInfo.rightNumber}}
						 
						 </text>
						 </view>
						<view>
						 <text class="footer-box__item">错题 {{examInfo.errorNumber}}</text>
						 </view>
						<view>
						 <text class="footer-box__item">正确率 {{examInfo.rightRate}}</text>
						 </view>
					</view>
				</block>
			</uni-card>
		</view>
		
		<button type="primary" @click="goExamDetail" class="btn" >查 看 答 案 解 析</button>
		<button type="warn" class="btn">再 来 一 次</button>
	</view>
</template>

<script>
	import uniSection from '@/components/uni-section/uni-section.vue' 
	import uniCard from '@/components/uni-card/uni-card.vue' 
	import uniBadge from '@/components/uni-badge/uni-badge.vue' 
	import { mapGetters } from 'vuex'
	export default {
		components: {uniSection, uniCard, uniBadge},
		data() {
			return {
				examInfoId: null,
				examInfo: {}
			}
		},
		
		computed: {
			...mapGetters({
				studentInfo: 'user/getStudentInfo'
			})
		},
		
		onLoad(params) {
			this.examInfoId = params.examInfoId
			this.getExamInfo()
		},
		
		methods: {
			
			getExamInfo () {
				this.$httpApi.get('/student/exam/selectExamInfo/' + this.examInfoId)
				.then(res => {
					this.examInfo = res.data
					let rightNumber = this.examInfo.rightNumber
					let questionNumber = this.examInfo.questionNumber
					let rightRate = rightNumber / questionNumber
					this.examInfo.rightRate = Number(rightRate * 100).toFixed(2) + '%'
				})
			},
			
			goExamDetail () {
				uni.navigateTo({
					url: './examDetail?examInfoId=' + this.examInfo.id
				})
			}
		}
	}
</script>

<style>
	@charset "UTF-8";

	/* 头条小程序组件内不能引入字体 */
	/* #ifdef MP-TOUTIAO */
	@font-face {
		font-family: uniicons;
		font-weight: normal;
		font-style: normal;
		src: url("~@/static/uni.ttf") format("truetype");
	}

	/* #endif */
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #efeff4;
		min-height: 100%;
		height: auto;
	}

   
	view {
		font-size: 14px;
		line-height: inherit;
	}

	.example {
		padding: 0 15px 15px;
	}
	
	.btn {
		margin-top: 40rpx; 
		width: 80%; 
		border-radius: 50rpx;
	}
	.save {
		background: rgb(0, 122, 255);
		border: none;
		color: #ffffff;
		line-height: 90rpx;
		margin-top: 40rpx;
		font-size: 30rpx;
	}

	.example-info {
		padding: 15px;
		color: #3b4144;
		background: #ffffff;
	}
	
	.uni-card__content-extra, .footer-box__item {
		font-size: 40rpx !important;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		padding: 0;
		font-size: 14px;
		background-color: #ffffff;
	}

	/* #endif */
	.example {
		padding: 0 15px;
	}

	.example-info {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 15px;
		color: #3b4144;
		background-color: #ffffff;
		font-size: 14px;
		line-height: 20px;
	}

	.example-info-text {
		font-size: 14px;
		line-height: 20px;
		color: #3b4144;
	}

	.example-body {
		flex-direction: column;
		padding: 15px;
		background-color: #ffffff;
	}

	.word-btn-white {
		font-size: 18px;
		color: #FFFFFF;
	}

	.word-btn {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		border-radius: 6px;
		height: 48px;
		margin: 15px;
		background-color: #007AFF;
	}

	.word-btn--hover {
		background-color: #4ca2ff;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 1px 0;
	}

	.example-box {
		margin: 12px 0;
	}

	.image-box {
		/* #ifndef APP-NVUE */
		display: flex;
		flex-direction: column;
		/* #endif */
		height: 350rpx;
		overflow: hidden;
	}

	.image {
		/* #ifndef APP-NVUE */
		width: 100%;
		height: 100%;
		/* #endif */
		flex: 1;
	}

	.content-box {
		padding-top: 20rpx;
	}

	.content-box-text {
		font-size: 12px;
		line-height: 22px;
	}

	.footer-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: space-between;
		flex-direction: row;
	}

	.footer-box__item {
		align-items: center;
		padding: 2px 0;
		font-size: 12px;
		color: #666;
	}
</style>